#
# Makefile for 'test'.
#
# Type 'make' or 'make test' to create the binary.
# Type 'make clean' or 'make clear' to delete all temporaries.
# Type 'make run' to execute the binary.
# Type 'make debug' to debug the binary using gdb(1).
#

# build target specs
CC = g++
CFLAGS = -O3 
OUT_DIR = release
LIBS =

# first target entry is the target invoked when typing 'make'
default: test

test: $(OUT_DIR)/Account.cpp.o $(OUT_DIR)/CheckingAccount.cpp.o $(OUT_DIR)/SavingsAccount.cpp.o $(OUT_DIR)/test.cpp.o
	$(CC) $(CFLAGS) -o test $(OUT_DIR)/Account.cpp.o $(OUT_DIR)/CheckingAccount.cpp.o $(OUT_DIR)/SavingsAccount.cpp.o $(OUT_DIR)/test.cpp.o $(LIBS)

$(OUT_DIR)/Account.cpp.o: Account.cpp Account.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/Account.cpp.o -c Account.cpp

$(OUT_DIR)/CheckingAccount.cpp.o: CheckingAccount.cpp CheckingAccount.h \
 Account.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/CheckingAccount.cpp.o -c CheckingAccount.cpp

$(OUT_DIR)/SavingsAccount.cpp.o: SavingsAccount.cpp SavingsAccount.h \
 Account.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/SavingsAccount.cpp.o -c SavingsAccount.cpp

$(OUT_DIR)/test.cpp.o: test.cpp Account.h SavingsAccount.h \
 CheckingAccount.h
	$(CC) $(CFLAGS) -o $(OUT_DIR)/test.cpp.o -c test.cpp

run:
	./test 

debug:
	gdb ./test

clean:
	@echo -n 'Removing all temporary binaries... '
	@rm -f test $(OUT_DIR)/*.o
	@echo Done.

clear:
	@echo -n 'Removing all temporary binaries... '
	@rm -f test $(OUT_DIR)/*.o
	@echo Done.

